package com.dzsw;

import cn.hutool.core.util.HexUtil;
import com.dzsw.datastruct.tree.binary.Node;
import org.apache.logging.log4j.core.config.Configurator;

import java.math.BigDecimal;

public class Main {
    public static void main(String[] args) {
        Configurator.initialize("Main", Main.class.getClassLoader(), "classpath:log4j2.xml");
        Node node = Node.createNode(null, null);
        int hashCode = System.identityHashCode(node);
        System.out.println("hashCode=" + hashCode);
        System.out.println("hashCode=" + HexUtil.toHex(hashCode));
        System.out.println("null=" + HexUtil.toHex(System.identityHashCode(null)));
        System.out.printf("hashCode=0x%x\n", hashCode);

        String s1 = "hello";
        String s2 = "hello";
        String s3 = new String("hello");
        StringBuilder sb = new StringBuilder("hello");
        System.out.println("s1=" + HexUtil.toHex(System.identityHashCode(s1)));
        System.out.println("s2=" + HexUtil.toHex(System.identityHashCode(s2)));
        System.out.println("s3=" + HexUtil.toHex(System.identityHashCode(s3)));
        System.out.println("sb=" + HexUtil.toHex(System.identityHashCode(sb.toString())));

        String strNum = "1.01";
        BigDecimal b = new BigDecimal(strNum);
        System.out.println(b);

        String s4 = s3.intern();
        System.out.println("s4=" + HexUtil.toHex(System.identityHashCode(s4)));
        System.out.println("s3.intern() == s2 ? " + (s3.intern() == s2));
        System.out.println("s4 == s2 ? " + (s4 == s2));
    }
}